--- 'Positioned' instance for 'SNames'
module frege.compiler.instances.PositionedSName where

import Compiler.types.SNames
import Compiler.types.Positions


instance Positioned SName where
    is _ = "simple name"
    getpos Simple{id}        = Pos id id
    getpos With1{ty, id}     = Pos it id
        where !it = if ty.line < id.line then id else ty
    getpos With2{ns, ty, id} = Pos it id
        where !it = if ns.line < id.line
                    then if ty.line < id.line
                        then id
                        else ty
                    else ns
    getrange = getpos
